package com.sc.es.controller.backend;

import com.sc.es.common.ApiResponse;
import com.sc.es.common.HouseResult;
import com.sc.es.repo.HouseTagRepo;
import com.sc.es.service.IHouseTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author sc
 * Created on  2018/2/8
 */
@RestController
public class TagController {

    @Autowired
    private IHouseTagService houseTagService;

    @DeleteMapping("/admin/house/tag")
    public ApiResponse deleteTag(@RequestParam("houseId")Integer houseId,@RequestParam("tag")String tag){
        return  houseTagService.deleteTag(houseId,tag).isSuccess()?
                ApiResponse.ofStatus(ApiResponse.Status.SUCCESS):
                ApiResponse.ofStatus(ApiResponse.Status.INTERNAL_SERVER_ERROR);
    }

    @PostMapping("/admin/house/tag")
    public ApiResponse addTag(@RequestParam("houseId")Integer houseId,@RequestParam("tag")String tag){
        return houseTagService.addTag(houseId,tag).isSuccess()?
                ApiResponse.ofStatus(ApiResponse.Status.SUCCESS):
                ApiResponse.ofStatus(ApiResponse.Status.INTERNAL_SERVER_ERROR);
    }
}
